from tortoise import fields

from app.models.mixins import BaseModel


class RegionType(BaseModel):
    id = fields.BigIntField(pk=True)
    type = fields.CharField(max_length=256)

    class Meta:
        table = "region_type"


class Region(BaseModel):
    id = fields.BigIntField(pk=True)
    regionType = fields.ForeignKeyField(
        "models.RegionType", related_name="regions", on_delete=fields.CASCADE, null=True
    )
    accountId = fields.BigIntField()
    name = fields.CharField(max_length=256)
    parentRegion = fields.CharField(max_length=256, null=True)
    latitude = fields.FloatField()
    latitude1 = fields.FloatField()
    longitude = fields.FloatField()
    longitude1 = fields.FloatField()
    weather = fields.ForeignKeyField(
        "models.Weather", related_name="region", on_delete=fields.CASCADE, null=True
    )

    class Meta:
        table = "region"


class OsmRegion(BaseModel):
    id = fields.BigIntField(pk=True)
    name = fields.CharField(max_length=256)
    latitude = fields.FloatField()
    longitude = fields.FloatField()
